﻿<cfsilent>
	<cfscript>
		
		jsonAdvice = getProperty("serviceFactory").getBean("jsonAdvice");
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
	
		taskProp = getProperty("serviceFactory").getBean("taskPropertyAdvice");
		
		response = structNew();
		structInsert(response, "success", false, true);
		
		examId = event.getArg("EXID");
		
		transaction {
			
			/* 加载考试任务 */
			sql = "SELECT a.task_prog
					FROM t_resittask a 
					WHERE a.task_exrstid = :examId ";
				
			queryObj = new Query( datasource=application.dnsMaster ) ;
			queryObj.addParam( name="examId", value=examId, cfsqltype="cf_sql_char" );
			
			rs_examTask= queryObj.execute( sql=sql ).getResult();
			
			if ( rs_examTask.task_prog eq "2" ) {
				
				/* 更新考试状态为已发布 */
			
				TaskProgress = "3";
				
				sql = "UPDATE t_resittask a 
						SET a.task_prog = :TaskProgress 
						WHERE a.task_exrstid = :examId ";
						
				queryObj = new Query( datasource=application.dnsMaster ) ;
				queryObj.addParam( name="examId", value=examId, cfsqltype="cf_sql_char" );
				queryObj.addParam( name="TaskProgress", value=TaskProgress, cfsqltype="cf_sql_char" );
				
				queryObj.execute( sql=sql );
				
				
				
				structInsert(response, "success", true, true);
				
			}
			else {
				
				structInsert(response, "ExamID", examId, true);
				structInsert(response, "reason", "考试状态异常 未完成时间、地点编排", true);
				
			}
			
		}
		
	</cfscript>
</cfsilent><cfoutput>#jsonAdvice.encode(data:response, stringNumbers:true)#</cfoutput>